use axum::{
    http::StatusCode,
    response::{IntoResponse, Response},
    Json,
};
use serde_json::json;
use tracing::error;

pub async fn error_handler(err: axum::Error) -> Response {
    error!("请求处理错误: {:?}", err);
    
    let error_response = json!({
        "success": false,
        "message": "服务器内部错误",
        "error": err.to_string()
    });

    (StatusCode::INTERNAL_SERVER_ERROR, Json(error_response)).into_response()
} 